package com.syni.mdd.yhd.common.all.config.pay.wxPay;

import com.syni.mdd.sjb.common.component.utils.common.utils.SpringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @className WxPayBeanFactory
 * @description TOO
 * @Author cfx
 * @DATE 2019/11/29 15:23
 * @VERSION 1.0
 **/
@Component
public class WxPayBeanFactory {


    public static String DEV_BACK_URL;

    @Value("${DEV_BACK_URL:http://dg.syni.com}")
    public void setDevBackUrl(String devBackUrl) {
        DEV_BACK_URL = devBackUrl;
    }

    public final static String MIN_APP_CHANNEL = "MIN_APP";
    public final static String PUBLIC_APP_CHANNEL = "PUB_APP";
    public final static String APP_CHANNEL = "APP";
    public final static String MIDONGDONG_APP_CHANNEL = "MDD_APP";
    public final static String APP_MDD_DATA_BANK_CHANNEL = "MDD_DATA_TREASURE";
    private static Map<String, WxPayBean> wxPayBeanMap = new LinkedHashMap<>();

    public static void addProperties(String key, WxPayBean wxPayBean) {
        wxPayBeanMap.put(key, wxPayBean);
    }

    public static WxPayBean getProperties(String key) {
        if(!wxPayBeanMap.containsKey(key)){
            wxPayBeanMap.put(key,(WxPayBean)SpringUtils.getBean(key));
        }
        return wxPayBeanMap.get(key);
    }
}
